home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / owlbwcc.zip / BDDVTBTN.CPP next >
C/C++ Source or Header  |  1992-01-26  |  5KB  |  128 lines

  1. /**********************************************************************/
  2. /*                  BDDVTBTN.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 1/26/92                 */
  4. /*          This program shows how to switch to different             */
  5. /*           routines based on the button pressed using               */
  6. /*           Dynamic Dispatched Virtual Tables, DDVT                  */
  7. /**********************************************************************/
  8. #include <owl.h>
  9. #include <dialog.h>
  10. #include "bwcc.h"                        // needed for BWCC
  11.  
  12. class TMyDialog : public TDialog
  13.   {
  14.   public:
  15.     TMyDialog(LPSTR lpDialogName)          // constructor calls
  16.       : TDialog(NULL,lpDialogName)         // base class constructor
  17.       {
  18.       BWCCGetVersion();    // activate Borland Windows Custom Controls
  19.       }
  20.     virtual void Ok(RTMessage Msg);        // redefines the DDVT function
  21.                        // for the OK button #1
  22.                        // as defined in Base class
  23.                        // TDialog
  24.     virtual void Cancel(RTMessage Msg);    // redefines the DDVT for the
  25.                        // cancel button in TDialog
  26.  
  27.     // The following Dynamic Dispatch Virtual Functions are linked
  28.     // to their associated subroutines
  29.  
  30.     virtual void HandleAbort(RTMessage Msg)
  31.       = [ID_FIRST + IDABORT];                // IDABORT is Button 3
  32.     virtual void HandleRetry(RTMessage Msg)
  33.       = [ID_FIRST + IDRETRY];                // IDRETRY is Button 4
  34.     virtual void HandleIgnore(RTMessage Msg)
  35.       = [ID_FIRST + IDIGNORE];               // IDIGNORE is Button 5
  36.     virtual void HandleYes(RTMessage Msg)
  37.       = [ID_FIRST + IDYES];                  // IDYES is Button 6
  38.     virtual void HandleNo(RTMessage Msg)
  39.       = [ID_FIRST + IDNO];                   // IDNO is Button 7
  40.     virtual void HandleButton8(RTMessage Msg)
  41.       = [ID_FIRST + 8];                      // Button #8
  42.  
  43.     virtual void DefChildProc(RTMessage Msg);  // Default handler for
  44.                            // Buttons not covered
  45.                            // by DDVT
  46.   };
  47. void TMyDialog::Ok(RTMessage Msg)  // Redefines button handler inherited
  48.   {                                // from TDailog for Button #1 IDOK
  49.   BWCCMessageBox(HWindow,"It will now call the IDOK in TDialog that will close this Dialog",
  50.              "Button #1 was pressed",MB_OK);
  51.   TDialog::Ok(Msg);
  52.   }
  53. void TMyDialog::Cancel(RTMessage Msg)  // Redefines button handler inherited
  54.   {                                    // from TDailog for Button #2 IDCANCEL
  55.   BWCCMessageBox(HWindow,"It will now call the IDCANCEL in the base classTDialog",
  56.              "Button #2 was pressed",MB_OK);
  57.   TDialog::Cancel(Msg);
  58.   }
  59.  
  60. void TMyDialog::HandleAbort(RTMessage)
  61.   {
  62.   BWCCMessageBox(HWindow,"The Abort Button was pressed",
  63.               "Button #3 was pressed",MB_OK);
  64.   }
  65. void TMyDialog::HandleRetry(RTMessage)
  66.   {
  67.   BWCCMessageBox(HWindow,"The Retry button was pressed",
  68.              "Button #4 was pressed",MB_OK);
  69.   }
  70. void TMyDialog::HandleIgnore(RTMessage)
  71.   {
  72.   BWCCMessageBox(HWindow,"The Ignore button was pressed",
  73.               "Button #5 was pressed",MB_OK);
  74.   }
  75. void TMyDialog::HandleYes(RTMessage)
  76.   {
  77.   BWCCMessageBox(HWindow,"The Yes button was pressed",
  78.              "Button #6 was pressed",MB_OK);
  79.   }
  80. void TMyDialog::HandleNo(RTMessage)
  81.   {
  82.   BWCCMessageBox(HWindow,"The No Button was pressed",
  83.              "Button #7 was pressed",MB_OK);
  84.   }
  85. void TMyDialog::HandleButton8(RTMessage)
  86.   {
  87.   BWCCMessageBox(HWindow,"The Button labled Button was pressed",
  88.               "Button #8 was pressed",MB_OK);
  89.   }
  90.  
  91. void TMyDialog::DefChildProc(RTMessage Msg)
  92.   {
  93.   MessageBeep(0);
  94.   BWCCMessageBox(HWindow,"Not Implemented","Feature",MB_OK);
  95.   MessageBeep(0);
  96.   TDialog::DefChildProc(Msg);
  97.   }
  98.  
  99. class TDialog1App : public TApplication  // Application Class to contain
  100.   {                                      // the application
  101.   public:
  102.     TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  103.         HANDLE hPrevInstance,            // base class constructor
  104.         LPSTR lpCmdLine, int nCmdShow)
  105.         :TApplication(lpName, hInstance,
  106.                   hPrevInstance,
  107.                   lpCmdLine, nCmdShow) {};
  108.  
  109.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  110.   };
  111.  
  112. void TDialog1App::InitMainWindow() // to initialize a dialog box
  113.   {                                // as the main window
  114.   MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  115.   }
  116.  
  117. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  118.            HANDLE hPrevInstance,          // windows to this program
  119.            LPSTR lpCmdLine , int nCmdShow)
  120.   {
  121.   TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
  122.                hPrevInstance,             // the dialog application
  123.                lpCmdLine,nCmdShow);
  124.   Dialog1.Run();                                  // run it
  125.   return (Dialog1.Status);                        // exit
  126.   }
  127. /**********************************************************************/
  128.